import Vue from 'vue'
import Router from 'vue-router'

import Layout from '@/views/layout/index'
import Login from '@/views/login/index'

Vue.use(Router)

export const constantRouterMap = [
  {
    path: '/login',
    name: 'Login',
    component: Login
  },
  {
    path: '',
    component: Layout,
    redirect: '/dashboard',
    children: [{
      path: 'dashboard',
      name: 'dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: {title: '首页', icon: 'home'}
    }]
  },
  {
    path: '/admin',
    name: 'manager',
    component: Layout,
    redirect: '/admin/sysuser',
    meta: {title: '系统管理', icon: 'setting'},
    children: [
      {
        path: 'sysuser',
        name: 'sysuser',
        component: () => import('@/views/admin/sysuser/index'),
        meta: {title: '用户管理', icon: 'sys-user'}
      },
      {
        path: 'updateSysUser',
        name: 'updateSysUser',
        component: () => import('@/views/admin/sysuser/update'),
        meta: {title: '修改系统用户', icon: 'add'},
        hidden: true
      },
      {
        path: 'sysrole',
        name: 'sysrole',
        component: () => import('@/views/admin/sysrole/index'),
        meta: {title: '角色管理', icon: 'sys-role'}
      },
      {
        path: 'syspermission',
        name: 'syspermission',
        component: () => import('@/views/admin/syspermission/index'),
        meta: {title: '权限管理', icon: 'sys-permission'}
      }
    ]
  },
  {
    path: '/admin',
    name: 'monitor',
    component: Layout,
    redirect: '/admin/syslog/index',
    meta: {title: '系统监控', icon: 'setting'},
    children: [
      {
        path: 'online',
        name: 'online',
        component: () => import('@/views/admin/sysuser/online'),
        meta: {title: '在线用户', icon: 'online'}
      },
      {
        path: 'syslog',
        name: 'syslog',
        component: () => import('@/views/admin/syslog/index'),
        meta: {title: '日志管理', icon: 'sys-log'}
      }
    ]
  }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({y: 0}),
  routes: constantRouterMap
})
